帮帮忙一道c语言题~~~`

来源:百度知道 编辑:UC知道 时间:2024/06/16 00:10:51
1、 设计函数,用来统计一个字符串中字母、数字、空格及其他字符的个数。

#include<stdio.h>
void main()
{char c;
int e=0,s=0,n=0,o=0;
for(;c!='#';)
{
scanf("%c",&c);
if ((c>='A'&&c<='Z')||(c>='a'&&c<='z')) e++;
else if (c==' ') s++;
else if (c>='0'&&c<='9') n++;
else o++;
}
printf("character=%d,space=%d,number=%d,other=%d",e,s,n,o);

在输入#之后 开始统计跳出循环